﻿using blackhouse.WebNemo.Business.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.WebNemo.Business.Exceptions {
    public class NemoException : Exception {

        #region Fields

        protected int exceptionId;

        #endregion

        #region Properties

        public string ExceptionTitle {
            get;
            private set;
        }

        public string ExceptionDescription {
            get;
            private set;
        }

        #endregion

        #region Constructors

        public NemoException(int exceptionId, Exception innerException)
            : base(GetTitle(exceptionId), innerException) {
            this.exceptionId = exceptionId;
            if (!this.ResourceExceptionExist())
                this.exceptionId = 0;
            this.ExceptionTitle = this.GetTitle();
            this.ExceptionDescription = this.GetDescription();
        }

        #endregion

        #region Methods

        private bool ResourceExceptionExist() {
            return Resources.ResourceManager.GetObject("Exception" + this.exceptionId + "_Title") != null;
        }

        private string GetTitle() {
            return GetTitle(this.exceptionId);
        }

        private static string GetTitle(int exceptionId) {
            return Resources.ResourceManager.GetString("Exception" + exceptionId + "_Title");
        }

        private string GetDescription() {
            return GetDescription(this.exceptionId);
        }

        private string GetDescription(int exceptionId) {
            return Resources.ResourceManager.GetString("Exception" + exceptionId + "_Description");
        }

        #endregion

    }
}
